<!--
 * @Description: 人员旅馆信息
 * @Author: 丁飞洋
 * @Date: 2025-09-10 14:20:52
 * @LastEditTime: 2025-09-12 14:40:20
 * @LastEditors: 丁飞洋
-->
<template>
  <div class="abnormalAccommodation">
    <div class="box">
      <div class="right">
        <div class="img"> <a-image style="width: 110px;height:128px;" :src="img" /> </div>
        <div class="text">{{ sfzh }}</div>
      </div>
      <div class="left">
        <a-table :data-source="dataSource" :columns="columns" size="small" :pagination="pagination" :loading="loading"
          @change="handleTableChange">
        </a-table>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, reactive, onMounted } from 'vue'
import { getYCZSList, getRxImg } from '@/api/fulldimensionalApi.js'
import { message } from 'ant-design-vue';
// 接受父组件传值
const props = defineProps({
  zjhm: {
    type: String,
    required: true
  }
})
// 首次加载
onMounted(() => {
  sfzh.value = props.zjhm
  console.log('父组件数据:', props.zjhm);
  fetchData()
  getImageData()
})
// 加载
const loading = ref(false)
// 人像
const img = ref("")
// 证件号码
const sfzh = ref("")
// 列表数据
const dataSource = ref([

])
// 列表表头
const columns = ref([
  {
    title: '酒店名称',
    dataIndex: 'jdmc',
    ellipsis: true,
    width: '220',
  }, {
    title: '入店时间',
    dataIndex: 'rzsj',
    width: '180',
  }, {
    title: '离店时间',
    dataIndex: 'ldsj',
    width: '180',
  },
])
// 分页数据
const pagination = ref({
  current: 1,
  pageSize: 5,
  total: 0,
  showSizeChanger: true,
  pageSizeOptions: ['5', '10', '20'],
  showTotal: total => `共 ${total} 条`
})
// 分页改变
const handleTableChange = (pag) => {
  pagination.current = pag.current
  pagination.pageSize = pag.pageSize
  fetchData()
}
// 请求列表数据
const fetchData = async () => {
  const params = {
    gmsfzhm: sfzh.value,
    pageNo: pagination.value.current,
    pageSize: pagination.value.pageSize
  };

  loading.value = true;
  getYCZSList(params).then((res) => {
    loading.value = false;
    if (res.code == 200) {
      dataSource.value = res.result.records;
      pagination.total = res.result.total
    } else {
      message.error(res.msg);
    }
  }).catch((err) => {
    loading.value = false;
    message.error(err);
  });
}
// 请求人员图片
const getImageData = async () => {
  const res = await getRxImg({ gmsfzhm: sfzh.value })
  img.value = "data:image/png;base64" + res.result
}
</script>

<style scoped>
.abnormalAccommodation {
  max-height: 310px;
  background-color: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  border: 1px solid #e5e7eb;
  padding: 10px 24px;
  overflow-y: auto;
}

.box {
  width: 100%;
  display: flex;
  justify-items: flex-start;
}

.right {
  width: 120px;
  margin-right: 16px;
}

.left {
  flex: 1;
}

.img {
  width: 110px;
  height: 128px;
  padding-left: 5px;
}

.text {
  font-size: 12px;
  color: #1677ff;
}
</style>
